﻿using DeviceManager.DB;
using DeviceManager.DB.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DeviceManager.ContentPage.SysMng
{
    /// <summary>
    /// WindowDepSelected.xaml 的交互逻辑
    /// </summary>
    public partial class WindowDepSelected : Window
    {

        /// <summary>
        /// 当前选择的对象
        /// </summary>
        internal DepmentInfo NowSelectedInfo = null;

        /// <summary>
        /// 部门信息集合
        /// </summary>
        private List<DepmentInfo> depInfo = null;
        public WindowDepSelected()
        {
            InitializeComponent();
            this.Loaded += WindowDepSelected_Loaded;
        }

        private void WindowDepSelected_Loaded(object sender, RoutedEventArgs e)
        {
            depInfo = ManagerDBCtrl.GetMng().GetAllDepmentInfos();
            depTree.ItemsSource = depInfo;
        }

        private void blt_Ok_Click(object sender, RoutedEventArgs e)
        {
            if (depTree.SelectedItem is DepmentInfo)
            {
                NowSelectedInfo = depTree.SelectedItem as DepmentInfo;
                this.DialogResult = true;
            }
            else
            {
                this.DialogResult = false;
            }
        }

        private void blt_Cannel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                    this.DragMove();
            }
            catch { }
        }
    }
}
